package cool.qingqing.consumer;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

/**
 * @author 高山青
 * @Date 2022/1/2  -   18:12
 */
public class ComsumerDemo02 {
	/**
	 * 函数式接口有哪些
	 * Supplier没有参数只有返回值
	 * Predicate有参数返回值是Boolean
	 * Function有参数也有返回值
	 * Consumer有参数没有返回值
	 *
	 */
	public static void main(String[] args) {
		String all=getAll(()->"查询所有！");
		System.out.println(all);
		getMassage(name->System.out.println(name));
		String getname=getAll(name->name+"查询所有！");
		System.out.println(getname);
		boolean r=isNull(name->name==null || "".equals(name)?true:false);
		System.out.println("是空的"+r);

		select(msg->System.out.println(msg+"转大写"),msg->System.out.println(msg+"转小写"));
	}
	public static String getAll(Supplier<String> stringSupplier){
		return stringSupplier.get();
	}
	public static void getMassage(Consumer<String> consumer){
		consumer.accept("看看我发的消息吧！");
	}

	public static String getAll(Function<String,String> function){
		return function.apply("Hello 高山青");
	}

	public static boolean isNull(Predicate<String> predicate){

		return predicate.test("高山青");
	}

	public static void select(Consumer<String> c1,Consumer<String> c2){
		String msg="Hello Word";
		c2.andThen(c1).accept(msg);
	}

}
